import torch
from torchvision import transforms
from cnn_net import CNN_NET
from mydataset import MyDataset

# 加载已保存的模型
model = torch.load('eyes.pth')
myTransforms = transforms.Compose([
    transforms.ToTensor(),
    transforms.Resize((20, 50))

])
# 处理本地图片
test_data = MyDataset(r'.\data\val\img', r'.\data\val\label\labels.csv', transform=myTransforms)

model.eval()

while 1:
    index = int(input())
    with torch.no_grad():
        output = model(test_data.__getitem__(index)[0].unsqueeze(0))

    out = output.tolist()
    x=out[0][0]
    y=out[0][1]

    print(index,
          "真实值",
          int(((test_data.__getitem__(index)[1][0] + 1) / 2) * 2560),
          int(((test_data.__getitem__(index)[1][1] + 1) / 2) * 1600),
          "预测值",
          int(((x + 1) / 2) * 2560),
          int(((y + 1) / 2) * 1600)
          )
